<!DOCTYPE html>
<html>
<head>
    <title>{$platform.name}</title>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
    <!--引用layui弹框插件-->
    <script src="/static/layui/layui.all.js"></script>
    <script src="/static/layui/layui.js"></script>
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/lay/modules/layer.js"></script>

    <!--弹框js-->
    <script src="/static/js/yii.js"></script>

    {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}
</head>
<body>
<style>
    html, body{background-color:#FFF!important;}
    .modal-body{background-color:#fff;padding:15px}
    .page-header{margin-top:15px!important;}
    .add_button{border-top:1px solid #eee;padding-top:15px;}
    .config_img {
        height:65px;
        margin-top: 15px;
    }
    .layui-form-pane .layui-form-label{font-size:12px!important;}
    .modal-body{display: inline-block;padding-bottom:78px;}
</style>

<div class="modal-body">

    <fieldset class=" layui-field-title" >
        <legend>添加账号</legend>
    </fieldset>


    <form class="layui-form layui-form-pane form-horizontal" action="" >

        <div class="layui-form-item layui-col-md9">
            <label class="layui-form-label">*姓名</label>
            <div class="layui-col-md4">
                <input type="text" name="name" class="layui-input"  placeholder="姓名">
            </div>
        </div>



        <div class="layui-form-item layui-col-md9">
        <label class="layui-form-label">*账号</label>
        <div class="layui-col-md4">
            <input type="text" name="mobile" placeholder="账号" class="layui-input">
        </div>
        </div>

        <div class="layui-form-item layui-col-md9">
            <label class="layui-form-label">*密码</label>
            <div class="layui-col-md4">
                <input type="text" name="password" class="layui-input"  placeholder="密码">
            </div>
        </div>

        <div class="layui-form-item layui-col-md9">
            <label class="layui-form-label">*确认密码</label>
            <div class="layui-col-md4">
                <input type="text" name="password1" class="layui-input"  placeholder="确认密码">
            </div>
        </div>

        <div class="layui-form-item layui-col-md4">
            <label class="layui-form-label">关联用户</label>
            <div class="layui-input-block">
                <div class="input-group ">
                    <input type="text" id="user" value="" class="layui-input" disabled >
                    <input type="hidden" name="fans_id" value="" class="layui-input" >
                    <span class="input-group-btn">
                        <button class="btn btn-default" id="user_btn" type="button">选择用户</button>
                    </span>
                </div>
            </div>
        </div>

        <div class="layui-form-item layui-col-md2">
            <label class="layui-form-label">*状态</label>
            <div class="layui-input-block">
                <select name="status">
                    <option value="1">启用</option>
                    <option value="2">禁用</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item layui-col-md2">
            <label class="layui-form-label">*点评权限</label>
            <div class="layui-input-block">
                <select name="comment">
                    <option value="1">启用</option>
                    <option value="2">禁用</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item layui-col-md9">
            <label class="layui-form-label">备注</label>
            <div class="layui-col-md4">
                <textarea name="remark" placeholder="备注" class="layui-textarea"></textarea>
            </div>
        </div>


    </form>

</div>
<div class="add_button">
    <div class="layui-form-item">
        <div class="layui-col-md-offset1">
            <a type="button" class="layui-btn layui-btn-primary" href="{:URL('project/account/index')}" >取消</a>
            <button type="button" class="layui-btn" id="newsave" >保存</button>
        </div>
    </div>
</div>


<script>
    var newModal = new yii.modal();

    $("#newsave").click(function () {
        var data = $("form").serializeArray();
        $.ajax({
            type: 'post',
            url: "{:URL('project/account/add')}",
            data: data,
            dataType: 'JSON',
            success: function (res) {
                if (res.code != 0) {
                    layer.alert(res.msg);
                } else {
                    window.location.href = "{:URL('project/account/index')}";
                }
            },
            error: function (res) {
            }
        });
    });

    layui.use(['form','laydate','transfer'], function() {
        //关联用户
        $("#user_btn").click(function () {
            newModal.initialization({
                url: "{:URL('common/Common/userList')}",
                type: "post",
                data:{
                    type:'detail'
                }
            });
        });
        newModal.on("user_add",function(data){
            var id=$(newModal.getid()).find(".js_add").attr("data-id");
            var name=$(newModal.getid()).find(".js_add").attr("data-name");
            $('#user').val(name);
            $('input[name="fans_id"]').val(id);
        });
    });
</script>

</body>
</html>